package com.szrt;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;

public class TestPostP {

	public static void testPost() throws IOException {
		
		URL url = new URL("http://www.lanz.net.cn/LANZGateway/DirectSendSMSs.asp");
		HttpURLConnection connection = (HttpURLConnection)url.openConnection();
                connection.setRequestMethod("POST");
		connection.setDoOutput(true);
                connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");              
		OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(), "GB2312");

		  String urlString = "UserID=999999&Account=lanz2016&Password=735FF0028B7831D2783DD7EE98E3095DB94A1"
				  +"D64&Content=您的注册验证码为8268，该验证码10分钟内有效。如非本人操作请忽略此短信！【浪驰软件】"
				  +"&Phones=11111111111&ReturnXJ=1";
          
		urlString = urlString.replace("%","％");
		urlString = urlString.replace("+","＋");
		urlString = urlString.replace(" ","+");


		out.write(urlString);
		out.flush();
		out.close();
		
		String sCurrentLine;
		String sTotalString;
		sCurrentLine = "";
		sTotalString = "";
		InputStream l_urlStream;
		l_urlStream = connection.getInputStream();

		BufferedReader l_reader = new BufferedReader(new InputStreamReader(l_urlStream));
		while ((sCurrentLine = l_reader.readLine()) != null) 
		{
			sTotalString += sCurrentLine + "\r\n";
		}
		System.out.println(sTotalString);
	}

	
	public static void main(String[] args) throws IOException{
         testPost();
	 }

}